package com.ophiux.member.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ophiux.common.core.base.Result;
import com.ophiux.member.model.dto.MemberCardDTO;
import com.ophiux.member.model.vo.MemberCardAddVo;
import com.ophiux.member.model.vo.MemberCardQueryVo;
import com.ophiux.member.service.IMemberCardService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/member/card")
@Api(tags = "名片")
public class MemberCardController {
	@Autowired
    IMemberCardService memberCardService;
	
	
	@ApiOperation("2.查询名片字段及对应的值")
    @GetMapping
    public Result<IPage<MemberCardDTO>> list(@RequestParam(required = false, defaultValue = "1") Integer current,
											 @RequestParam(required = false, defaultValue = "30") Integer size, MemberCardQueryVo queryDTO) {
		IPage<MemberCardDTO> page = memberCardService.getPage(new Page<>(current, size), queryDTO);
        return Result.success(page);
    }
	
	
	@ApiOperation("3.新增-保存名片")
	@PostMapping("/add")
	public Result add(@RequestBody List<MemberCardAddVo> list) {
		return memberCardService.insertBatch(list);
	}
	
	
}
